Skip to content

Introduce custom JavaDoc tags #565 #585

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 29 commits into from
Aug 24, 2022
Merged

Conversation

onewhl
Copy link
Member

@onewhl onewhl commented Jul 25, 2022

Description

Introduce custom JavaDoc tags to make generated code comments structured.

@utbot.classUnderTest - Inline link to the enclosing class.
@utbot.methodUnderTest - Inline link to the method we test.
@utbot.expectedResult - Value we expect to get.
@utbot.actualResult - Value we got.
@utbot.executes - Executed condition.
@utbot.invokes - Invoked method.
@utbot.returnsFrom - Statement we return from.
@utbot.throwsException - Thrown exception.

The list of tags could be expanded

We show only tags that have some non-null value. After plugin's removal, IDE doesn't recognize our custom tags. It doesn't lead to errors, but highlights tags with yellow color.

TODO: Add a test in the intellij module in separate PR
TODO: @amandelpie suggested to add a tag for display name in (PR-624) in case of JUnit4 in separate PR.
TODO: After upgrading to 2022.1 fix comment rendering in separate PR by using default JavaDocInfoGenerator.

Fixes #565

Type of Change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Automated Testing

Run tests SummaryConditionsTest, SummaryMinStackTest, SummaryExceptionClusteringExamplesTest.

Manual Scenario

Set useFuzzing = false and useCustomJavaDocTags=true in UtSettings.

Case 1: check that tags are supported and shown in IDE.

  1. Open any Java project in IntelliJ IDEA.
  2. Add JavaDoc comment above any method and start typing @utbot -> you will notice that completion works and our custom tags are shown.
  3. You can also render comment clicking toggle on the right side of the comment.

Case 2: check that the plugin generates comments using custom tags.

  1. Open any Java project in IntelliJ IDEA
  2. Click on any class/method and select Create tests with UTBot action
  3. Check the comments under generated tests.

Tested using runIde command.

Checklist (remove irrelevant options):

  • The change followed the style guidelines of the UTBot project
  • Self-review of the code is passed
  • The change contains enough commentaries, particularly in hard-to-understand areas
  • New documentation is provided or existed one is altered
  • No new warnings
  • New tests have been added
  • All tests pass locally with my changes

@onewhl onewhl added the comp-summaries Something related to the method names, code comments and display names generation label Jul 25, 2022
@onewhl onewhl requested a review from amandelpie July 25, 2022 15:03
@onewhl onewhl force-pushed the onewhl/565_custom_javadoc_tags branch 3 times, most recently from 55d9b35 to 38ca8c6 Compare August 8, 2022 07:51
@onewhl onewhl marked this pull request as ready for review August 8, 2022 07:54
@onewhl
Copy link
Member Author

onewhl commented Aug 8, 2022

I would like to discuss several things.

  • Is it OK to change global settings from UtSettings in tests (see SummaryTestCaseGeneratorTest)? The order of tests is non-determined, it seems it possible could lead to errors. I used JUnit extension to avoid it.
  • Is it possible to show error message in CI logs in case test fail?

Damtev
Damtev previously requested changes Aug 8, 2022
@Damtev
Copy link
Member

Damtev commented Aug 9, 2022

I would like to discuss several things.

  • Is it OK to change global settings from UtSettings in tests (see SummaryTestCaseGeneratorTest)? The order of tests is non-determined, it seems it possible could lead to errors. I used JUnit extension to avoid it.
  • Is it possible to show error message in CI logs in case test fail?
  1. Mostly it is not OK, just because of your mentioned, reasons, so we use a lot of util functions that change them only for specific tests. You can see some examples in the org.utbot.examples.UtValueTestCaseChecker file, like withoutMinimization and others. But I suppose your way is acceptable too.
  2. I am not sure about common logs, but we publish some artifacts after a pipeline ending, that you can find in the pipeline summary tab. One of them is utbot_framework_logs, which is a simple gradle tests report. In this report, you can find logs and, most importantly, test output for each test.

@onewhl onewhl force-pushed the onewhl/565_custom_javadoc_tags branch from c067536 to 22b6623 Compare August 17, 2022 11:04
Copy link
Collaborator

@amandelpie amandelpie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make some minor changes

@onewhl onewhl force-pushed the onewhl/565_custom_javadoc_tags branch from 5ceb39f to bd616a9 Compare August 24, 2022 11:31
@amandelpie amandelpie enabled auto-merge (squash) August 24, 2022 12:14
@amandelpie amandelpie removed the request for review from EgorkaKulikov August 24, 2022 12:15
@amandelpie amandelpie dismissed Damtev’s stale review August 24, 2022 12:16

The most part of requirements were implemented

@amandelpie amandelpie merged commit 7c95c43 into main Aug 24, 2022
@amandelpie amandelpie deleted the onewhl/565_custom_javadoc_tags branch August 24, 2022 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-summaries Something related to the method names, code comments and display names generation
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Introduce custom JavaDoc tags to structure test summaries
3 participants